define(function(require, exports){
	// var $ = require("jquery");
	var pubjs = require('pubjs');
	var view  = require('@base/view');

	// 禁用人群标签 弹窗
	var PopDisabled = view.widget.extend({
		init: function( config ) {
			config = pubjs.conf( config, {
				'view_model': {
					'showGrid': false, // 隐藏表格
					'tagName': '', // 标签名
					'clickShowGrid': this.eventShowGrid // 点击查看活动列表
				}
			});
			this.$id = -1; // 人群标签Id
			this.$dataReady = false;
			this.Super( 'init', arguments );
		},
		afterBuild:function(){
			var el = this.getDOM();
			el.append([
				'<h2>',
					LANG('确定禁用“ '),
					'<span ms-text="tagName"></span>',
					LANG(' ”标签吗？'),
				'</h2>',
				'<p>',
					LANG('禁用标签后，将不可在活动设置中重定向选项里找到被禁用的标签；同时之前使用了被禁用标签的活动，标签的定向条件也会失效。点击“查看活动列表”按钮，可查看使用了该标签的活动列表。'),
				'</p>',
				'<div class="pb10">',
					'<a ms-click="clickShowGrid">'+ LANG('查看活动列表') +'</a>',
				'</div>',
				'<div ms-visible="showGrid" pub-name="grid" pub-mod="admin/peopleTag/grid/grid.campaignList"/>'
			].join(''));
			this.buildFromTemplate();
		},
		setTagInfo: function( id, name ) {
			this.$id = id;
			this.vm.$['tagName'] = name || '';
			return this;
		},
		eventShowGrid: function() {
			var vm = this.vm.$;
			vm['showGrid'] = !vm['showGrid'];
			if( vm['showGrid'] && !this.$dataReady ) {
				this.$dataReady = true;
				this.$['grid'].setParam({
					'vid': this.$id
				}).reload();
			}
		},
		onDialogOk: function() {
			this.fire( 'pauseTagOk', this.$id );
			return false;
		},
		reset: function() {
			this.vm.reset();
			this.$dataReady = false;
			return this;
		}
	});
	exports.popDisabled = PopDisabled;
});